package bairui.international.model.domain.jpa;


/**
 *
 * (产品订单项)TB_ProductOrderItem
 *
 * @说明
 * <pre>

 * </pre>
 *
 * @see Help_TB_ProductOrderItem#inheritance() 继承体系信息
 *
 */
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate

@javax.persistence.Entity(name="t_productOrderItem")
@com.lianjing.sh.processing.info.annotation.GenerateInfoModel
@SuppressWarnings("serial")
@com.lianjing.sh.model.common.annotation.Comment("产品订单项")
@com.lianjing.sh.processing.info.annotation.InfoComment("产品订单项")
public class TB_ProductOrderItem
 implements 
	com.lianjing.sh.model.common.stardard.TableModel<bairui.international.model.domain.jpa.id.ID_ProductOrderItem>,
	java.io.Serializable

{

	
	
	/**
	 * 必须属性赋值接口
	 */
	public static interface MustProperties{
		public bairui.international.model.domain.jpa.id.ID_ProductOrderItem getId();
		/** 数量 */
		public Long getAmount();
		/** 产品单价 */
		public Double getProductPerPrice();
		/** 产品总价 */
		public Double getProductTotalPrice();
		/** 类型 */
		public bairui.international.model.type.Type_ProductOrderItem getType();
		/** 产品积分 */
		public Double getProductScore();
		/** 产品总积分 */
		public Double getProductTotalScore();
	}
	
	/**
	 * 为必须属性赋值
	 */
	public TB_ProductOrderItem properties(MustProperties properties) {
		this.setId(properties.getId());
		this.setAmount(properties.getAmount());
		this.setProductPerPrice(properties.getProductPerPrice());
		this.setProductTotalPrice(properties.getProductTotalPrice());
		this.setType(properties.getType());
		this.setProductScore(properties.getProductScore());
		this.setProductTotalScore(properties.getProductTotalScore());
		return this;
	}
	
	/**
	 *	必须属性构造函数
	 */
	public TB_ProductOrderItem(MustProperties properties) {
		this.properties(properties);
	}
	
	
	/**
	 * 可选单属性赋值接口
	 */
	public static interface OptionalSingleProperties{
		/** 产品代码 */
		public String getProductNumber();
		/** 产品名称 */
		public String getProductName();
		/** 产品图片 */
		public String getProductImgUrl();
		/** 产品备注 */
		public String getProductComment();
		/** 产品单位 */
		public String getProductUnit();
		/** 分公司员工提成记录 */
		public bairui.international.model.domain.jpa.TB_BranchCompanyStaffRoyaltyRecord getBranchCompanyStaffRoyaltyRecord();
	}
	
	/**
	 * 为可选单属性赋值
	 */
	public TB_ProductOrderItem properties(OptionalSingleProperties properties) {
		this.setProductNumber(properties.getProductNumber());
		this.setProductName(properties.getProductName());
		this.setProductImgUrl(properties.getProductImgUrl());
		this.setProductComment(properties.getProductComment());
		this.setProductUnit(properties.getProductUnit());
		this.setBranchCompanyStaffRoyaltyRecord(properties.getBranchCompanyStaffRoyaltyRecord());
		return this;
	}
	
	
	
	public TB_ProductOrderItem(MustProperties must, OptionalSingleProperties optionalSingle) {
		this.properties(must);
		this.properties(optionalSingle);
	}
	
	
	
	/**
	 * 更新属性内部类
	 */
	public abstract class UpdateProperties {
	
		public UpdateProperties() throws Exception {
			bairui.international.model.domain.jpa.TB_Product product = getProduct(TB_ProductOrderItem.this);
			if(isOverride_getProduct){
				TB_ProductOrderItem.this.setProduct(product);
			}
	
			bairui.international.model.domain.jpa.TB_ProductOrder productOrder = getProductOrder(TB_ProductOrderItem.this);
			if(isOverride_getProductOrder){
				TB_ProductOrderItem.this.setProductOrder(productOrder);
			}
	
			Long amount = getAmount(TB_ProductOrderItem.this);
			if(isOverride_getAmount){
				TB_ProductOrderItem.this.setAmount(amount);
			}
	
			Double productPerPrice = getProductPerPrice(TB_ProductOrderItem.this);
			if(isOverride_getProductPerPrice){
				TB_ProductOrderItem.this.setProductPerPrice(productPerPrice);
			}
	
			Double productTotalPrice = getProductTotalPrice(TB_ProductOrderItem.this);
			if(isOverride_getProductTotalPrice){
				TB_ProductOrderItem.this.setProductTotalPrice(productTotalPrice);
			}
	
			String productNumber = getProductNumber(TB_ProductOrderItem.this);
			if(isOverride_getProductNumber){
				TB_ProductOrderItem.this.setProductNumber(productNumber);
			}
	
			String productName = getProductName(TB_ProductOrderItem.this);
			if(isOverride_getProductName){
				TB_ProductOrderItem.this.setProductName(productName);
			}
	
			String productImgUrl = getProductImgUrl(TB_ProductOrderItem.this);
			if(isOverride_getProductImgUrl){
				TB_ProductOrderItem.this.setProductImgUrl(productImgUrl);
			}
	
			String productComment = getProductComment(TB_ProductOrderItem.this);
			if(isOverride_getProductComment){
				TB_ProductOrderItem.this.setProductComment(productComment);
			}
	
			String productUnit = getProductUnit(TB_ProductOrderItem.this);
			if(isOverride_getProductUnit){
				TB_ProductOrderItem.this.setProductUnit(productUnit);
			}
	
			bairui.international.model.type.Type_ProductOrderItem type = getType(TB_ProductOrderItem.this);
			if(isOverride_getType){
				TB_ProductOrderItem.this.setType(type);
			}
	
			Double productScore = getProductScore(TB_ProductOrderItem.this);
			if(isOverride_getProductScore){
				TB_ProductOrderItem.this.setProductScore(productScore);
			}
	
			Double productTotalScore = getProductTotalScore(TB_ProductOrderItem.this);
			if(isOverride_getProductTotalScore){
				TB_ProductOrderItem.this.setProductTotalScore(productTotalScore);
			}
	
			bairui.international.model.domain.jpa.TB_BranchCompanyStaffRoyaltyRecord branchCompanyStaffRoyaltyRecord = getBranchCompanyStaffRoyaltyRecord(TB_ProductOrderItem.this);
			if(isOverride_getBranchCompanyStaffRoyaltyRecord){
				TB_ProductOrderItem.this.setBranchCompanyStaffRoyaltyRecord(branchCompanyStaffRoyaltyRecord);
			}
		}
	
		public TB_ProductOrderItem up(){
			return TB_ProductOrderItem.this;
		}
	
		/** 产品 */
		private boolean isOverride_getProduct = true;
		public bairui.international.model.domain.jpa.TB_Product getProduct(TB_ProductOrderItem it) throws Exception { 
			isOverride_getProduct = false; 
			return null;
		}
		/** 产品订单 */
		private boolean isOverride_getProductOrder = true;
		public bairui.international.model.domain.jpa.TB_ProductOrder getProductOrder(TB_ProductOrderItem it) throws Exception { 
			isOverride_getProductOrder = false; 
			return null;
		}
		/** 数量 */
		private boolean isOverride_getAmount = true;
		public Long getAmount(TB_ProductOrderItem it) throws Exception { 
			isOverride_getAmount = false; 
			return null;
		}
		/** 产品单价 */
		private boolean isOverride_getProductPerPrice = true;
		public Double getProductPerPrice(TB_ProductOrderItem it) throws Exception { 
			isOverride_getProductPerPrice = false; 
			return null;
		}
		/** 产品总价 */
		private boolean isOverride_getProductTotalPrice = true;
		public Double getProductTotalPrice(TB_ProductOrderItem it) throws Exception { 
			isOverride_getProductTotalPrice = false; 
			return null;
		}
		/** 产品代码 */
		private boolean isOverride_getProductNumber = true;
		public String getProductNumber(TB_ProductOrderItem it) throws Exception { 
			isOverride_getProductNumber = false; 
			return null;
		}
		/** 产品名称 */
		private boolean isOverride_getProductName = true;
		public String getProductName(TB_ProductOrderItem it) throws Exception { 
			isOverride_getProductName = false; 
			return null;
		}
		/** 产品图片 */
		private boolean isOverride_getProductImgUrl = true;
		public String getProductImgUrl(TB_ProductOrderItem it) throws Exception { 
			isOverride_getProductImgUrl = false; 
			return null;
		}
		/** 产品备注 */
		private boolean isOverride_getProductComment = true;
		public String getProductComment(TB_ProductOrderItem it) throws Exception { 
			isOverride_getProductComment = false; 
			return null;
		}
		/** 产品单位 */
		private boolean isOverride_getProductUnit = true;
		public String getProductUnit(TB_ProductOrderItem it) throws Exception { 
			isOverride_getProductUnit = false; 
			return null;
		}
		/** 类型 */
		private boolean isOverride_getType = true;
		public bairui.international.model.type.Type_ProductOrderItem getType(TB_ProductOrderItem it) throws Exception { 
			isOverride_getType = false; 
			return null;
		}
		/** 产品积分 */
		private boolean isOverride_getProductScore = true;
		public Double getProductScore(TB_ProductOrderItem it) throws Exception { 
			isOverride_getProductScore = false; 
			return null;
		}
		/** 产品总积分 */
		private boolean isOverride_getProductTotalScore = true;
		public Double getProductTotalScore(TB_ProductOrderItem it) throws Exception { 
			isOverride_getProductTotalScore = false; 
			return null;
		}
		/** 分公司员工提成记录 */
		private boolean isOverride_getBranchCompanyStaffRoyaltyRecord = true;
		public bairui.international.model.domain.jpa.TB_BranchCompanyStaffRoyaltyRecord getBranchCompanyStaffRoyaltyRecord(TB_ProductOrderItem it) throws Exception { 
			isOverride_getBranchCompanyStaffRoyaltyRecord = false; 
			return null;
		}
	
	}
	
	
	/**
	 * 构造函数
	 */
	public TB_ProductOrderItem() {
	}
	
	public TB_ProductOrderItem(
		@lombok.NonNull bairui.international.model.domain.jpa.id.ID_ProductOrderItem id
	) {
		this.setId(id);
	}
	
	public TB_ProductOrderItem(
		@lombok.NonNull TB_ProductOrderItem bean
	) {
		this.setId(bean.getId());
		this.setProduct(bean.getProduct());
		this.setProductOrder(bean.getProductOrder());
		this.setAmount(bean.getAmount());
		this.setProductPerPrice(bean.getProductPerPrice());
		this.setProductTotalPrice(bean.getProductTotalPrice());
		this.setProductNumber(bean.getProductNumber());
		this.setProductName(bean.getProductName());
		this.setProductImgUrl(bean.getProductImgUrl());
		this.setProductComment(bean.getProductComment());
		this.setProductUnit(bean.getProductUnit());
		this.setType(bean.getType());
		this.setProductScore(bean.getProductScore());
		this.setProductTotalScore(bean.getProductTotalScore());
		this.setBranchCompanyStaffRoyaltyRecord(bean.getBranchCompanyStaffRoyaltyRecord());
	}
	
	

	/**
	 * 联合主键
	 */
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.EmbeddedId
	@org.hibernate.annotations.Target(bairui.international.model.domain.jpa.id.ID_ProductOrderItem.class)
	private bairui.international.model.domain.jpa.id.ID_ProductOrderItem id;
	
	@com.fasterxml.jackson.databind.annotation.JsonSerialize(using=bairui.international.model.domain.jpa.id.ID_ProductOrderItem.CompositePKSerializer.class)
	public bairui.international.model.domain.jpa.id.ID_ProductOrderItem getId() {
		return this.id;
	}
	public void setId(bairui.international.model.domain.jpa.id.ID_ProductOrderItem id) {
		this.id = id;
		if(null != this.id){
			this.setProduct(this.id.getProduct());
			this.setProductOrder(this.id.getProductOrder());
		}
	}
	public void setId_only(bairui.international.model.domain.jpa.id.ID_ProductOrderItem id) {
		this.id = id;
	}
	


	/**
	 * 属性
	 */
	@com.lianjing.sh.model.common.annotation.Comment("产品")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToOne(optional=false)
	@javax.persistence.JoinColumn(insertable=false, updatable=false)
	private bairui.international.model.domain.jpa.TB_Product product;

	@com.lianjing.sh.model.common.annotation.Comment("产品订单")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品订单")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToOne(optional=false)
	@javax.persistence.JoinColumn(insertable=false, updatable=false)
	private bairui.international.model.domain.jpa.TB_ProductOrder productOrder;

	@com.lianjing.sh.model.common.annotation.Comment("数量")
	@com.lianjing.sh.processing.info.annotation.InfoComment("数量")
	@javax.persistence.Column(name="amount", nullable=false)
	private Long amount;

	@com.lianjing.sh.model.common.annotation.Comment("产品单价")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品单价")
	@javax.persistence.Column(name="productPerPrice", nullable=false)
	private Double productPerPrice;

	@com.lianjing.sh.model.common.annotation.Comment("产品总价")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品总价")
	@javax.persistence.Column(name="productTotalPrice", nullable=false)
	private Double productTotalPrice;

	@com.lianjing.sh.model.common.annotation.Comment("产品代码")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品代码")
	@javax.persistence.Column(name="productNumber", length=32)
	private String productNumber;

	@com.lianjing.sh.model.common.annotation.Comment("产品名称")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品名称")
	@javax.persistence.Column(name="productName", length=255)
	private String productName;

	@com.lianjing.sh.model.common.annotation.Comment("产品图片")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品图片")
	@javax.persistence.Column(name="productImgUrl", length=255)
	private String productImgUrl;

	@com.lianjing.sh.model.common.annotation.Comment("产品备注")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品备注")
	@javax.persistence.Column(name="productComment", length=32)
	private String productComment;

	@com.lianjing.sh.model.common.annotation.Comment("产品单位")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品单位")
	@javax.persistence.Column(name="productUnit", length=255)
	private String productUnit;

	@com.lianjing.sh.model.common.annotation.Comment("类型")
	@com.lianjing.sh.processing.info.annotation.InfoComment("类型")
	@javax.persistence.Enumerated(javax.persistence.EnumType.STRING)
	@javax.persistence.Column(name="type", nullable=false)
	private bairui.international.model.type.Type_ProductOrderItem type;

	@com.lianjing.sh.model.common.annotation.Comment("产品积分")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品积分")
	@javax.persistence.Column(name="productScore", nullable=false)
	private Double productScore;

	@com.lianjing.sh.model.common.annotation.Comment("产品总积分")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品总积分")
	@javax.persistence.Column(name="productTotalScore", nullable=false)
	private Double productTotalScore;

	@com.lianjing.sh.model.common.annotation.Comment("分公司员工提成记录")
	@com.lianjing.sh.processing.info.annotation.InfoComment("分公司员工提成记录")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.OneToOne(mappedBy="productOrderItem")
	private bairui.international.model.domain.jpa.TB_BranchCompanyStaffRoyaltyRecord branchCompanyStaffRoyaltyRecord;

	/** get[产品] */
	public bairui.international.model.domain.jpa.TB_Product getProduct() {
		return this.product;
	}

	/** get[产品订单] */
	public bairui.international.model.domain.jpa.TB_ProductOrder getProductOrder() {
		return this.productOrder;
	}

	/** get[数量] */
	public Long getAmount() {
		return this.amount;
	}

	/** get[产品单价] */
	public Double getProductPerPrice() {
		return this.productPerPrice;
	}

	/** get[产品总价] */
	public Double getProductTotalPrice() {
		return this.productTotalPrice;
	}

	/** get[产品代码] */
	public String getProductNumber() {
		return this.productNumber;
	}

	/** get[产品名称] */
	public String getProductName() {
		return this.productName;
	}

	/** get[产品图片] */
	public String getProductImgUrl() {
		return this.productImgUrl;
	}

	/** get[产品备注] */
	public String getProductComment() {
		return this.productComment;
	}

	/** get[产品单位] */
	public String getProductUnit() {
		return this.productUnit;
	}

	/** get[类型] */
	public bairui.international.model.type.Type_ProductOrderItem getType() {
		return this.type;
	}

	/** get[产品积分] */
	public Double getProductScore() {
		return this.productScore;
	}

	/** get[产品总积分] */
	public Double getProductTotalScore() {
		return this.productTotalScore;
	}

	/** get[分公司员工提成记录] */
	public bairui.international.model.domain.jpa.TB_BranchCompanyStaffRoyaltyRecord getBranchCompanyStaffRoyaltyRecord() {
		return this.branchCompanyStaffRoyaltyRecord;
	}

	/** set[产品] */
	public void setProduct(bairui.international.model.domain.jpa.TB_Product product) {
		this.product = product;
	}

	/** set[产品订单] */
	public void setProductOrder(bairui.international.model.domain.jpa.TB_ProductOrder productOrder) {
		this.productOrder = productOrder;
	}

	/** set[数量] */
	public void setAmount(Long amount) {
		this.amount = amount;
	}

	/** set[产品单价] */
	public void setProductPerPrice(Double productPerPrice) {
		this.productPerPrice = productPerPrice;
	}

	/** set[产品总价] */
	public void setProductTotalPrice(Double productTotalPrice) {
		this.productTotalPrice = productTotalPrice;
	}

	/** set[产品代码] */
	public void setProductNumber(String productNumber) {
		this.productNumber = productNumber;
	}

	/** set[产品名称] */
	public void setProductName(String productName) {
		this.productName = productName;
	}

	/** set[产品图片] */
	public void setProductImgUrl(String productImgUrl) {
		this.productImgUrl = productImgUrl;
	}

	/** set[产品备注] */
	public void setProductComment(String productComment) {
		this.productComment = productComment;
	}

	/** set[产品单位] */
	public void setProductUnit(String productUnit) {
		this.productUnit = productUnit;
	}

	/** set[类型] */
	public void setType(bairui.international.model.type.Type_ProductOrderItem type) {
		this.type = type;
	}

	/** set[产品积分] */
	public void setProductScore(Double productScore) {
		this.productScore = productScore;
	}

	/** set[产品总积分] */
	public void setProductTotalScore(Double productTotalScore) {
		this.productTotalScore = productTotalScore;
	}

	/** set[分公司员工提成记录] */
	public void setBranchCompanyStaffRoyaltyRecord(bairui.international.model.domain.jpa.TB_BranchCompanyStaffRoyaltyRecord branchCompanyStaffRoyaltyRecord) {
		this.branchCompanyStaffRoyaltyRecord = branchCompanyStaffRoyaltyRecord;
	}

	public void assignProduct(bairui.international.model.domain.jpa.TB_Product product) {
		if(null != product){
			product.addProductOrderItems(this);
		}
		this.setProduct(product);
	}
	

	public void assignProductOrder(bairui.international.model.domain.jpa.TB_ProductOrder productOrder) {
		if(null != productOrder){
			productOrder.addProductOrderItems(this);
		}
		this.setProductOrder(productOrder);
	}
	

	public void assignBranchCompanyStaffRoyaltyRecord(bairui.international.model.domain.jpa.TB_BranchCompanyStaffRoyaltyRecord branchCompanyStaffRoyaltyRecord) {
		if(null != branchCompanyStaffRoyaltyRecord){
			branchCompanyStaffRoyaltyRecord.setProductOrderItem(this);
		}
		this.setBranchCompanyStaffRoyaltyRecord(branchCompanyStaffRoyaltyRecord);
	}
	

	
	
	

	/** take[产品] */
	public bairui.international.model.domain.jpa.TB_Product takeProduct(){
		if(null == this.product){
			this.product = new bairui.international.model.domain.jpa.TB_Product();
		}
		return this.product;
	}
	
	/** take[产品订单] */
	public bairui.international.model.domain.jpa.TB_ProductOrder takeProductOrder(){
		if(null == this.productOrder){
			this.productOrder = new bairui.international.model.domain.jpa.TB_ProductOrder();
		}
		return this.productOrder;
	}
	
	/** take[分公司员工提成记录] */
	public bairui.international.model.domain.jpa.TB_BranchCompanyStaffRoyaltyRecord takeBranchCompanyStaffRoyaltyRecord(){
		if(null == this.branchCompanyStaffRoyaltyRecord){
			this.branchCompanyStaffRoyaltyRecord = new bairui.international.model.domain.jpa.TB_BranchCompanyStaffRoyaltyRecord();
		}
		return this.branchCompanyStaffRoyaltyRecord;
	}
	
	/** must[产品] */
	public bairui.international.model.domain.jpa.TB_Product mustProduct() {
		return this.product;
	}
	
	/** must[产品订单] */
	public bairui.international.model.domain.jpa.TB_ProductOrder mustProductOrder() {
		return this.productOrder;
	}
	
	/** optional[分公司员工提成记录] */
	public java.util.Optional<bairui.international.model.domain.jpa.TB_BranchCompanyStaffRoyaltyRecord> optionalBranchCompanyStaffRoyaltyRecord() {
		return java.util.Optional.ofNullable(this.branchCompanyStaffRoyaltyRecord);
	}
	

	/**
	 * 复写 hashCode
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		return prime * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
	}
	
	/**
	 * 复写 equals
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		TB_ProductOrderItem other = (TB_ProductOrderItem) obj;
		if (this.getId() == null) {
			return false;
		} else if (!this.getId().equals(other.getId())){
			return false;
		}
		return true;
	}
	

	/**
	 * 用来覆盖toString()的输出
	 */
	@javax.persistence.Transient
	private String toString;
	
	public void setToString(String toString) {
		this.toString = toString;
	}
	
	/**
	 * 复写 toString
	 */
	@Override
	public String toString() {
		if(null != this.toString){
			return this.toString;
		}
		return super.toString();
	}	

	@javax.persistence.PrePersist
	public void prePersist() {
	}
	
	@javax.persistence.PreUpdate
	public void preUpdate() {
	}



}
